package offer;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class offer64 {
    public static void main(String[] args) {
        Lock lock = new ReentrantLock();
        lock.lock();
        lock.unlock();
        Solution solution = new Solution();
        solution.sumNums(3);
        Solution2 solution2 = new Solution2();
        solution2.sumNums(3);
    }

    static class Solution {
        int res = 0;
        public int sumNums(int n) {
            boolean x = n > 1 && sumNums(n-1) > 0;
            res += n;
            return res;
        }
    }

    static class Solution2 {
        public int sumNums(int n) {
            boolean x = n > 1 && (n +=sumNums(n-1)) > 0;
            return n;
        }
    }
}
